/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package carstore.carstoreserver.controllers;
import carstore.carstoreserver.services.CarStoreRepository;
import carstore.carstoreserver.models.Carstore;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author wuhao
 */
@RestController
public class CarStoreController {
    @Autowired
    private CarStoreRepository CarStoreRepositoryImpl;

    @RequestMapping("/storecount")
    public long getcarcount()
    {
        return CarStoreRepositoryImpl.count();
    }
    @RequestMapping("/carstore")
    public List<Carstore> getcarByID(Integer storeId)
    {
        return CarStoreRepositoryImpl.findBystoreId(storeId);
    }

    @RequestMapping("/allstores")
    public List<Carstore> getall()
    {
        return (List<Carstore>) CarStoreRepositoryImpl.findAll();
    }
}
